#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_clicked()
{
    QDateTime timePrev = ui->dateTimeEdit->dateTime();
    QDateTime timeNow = ui->dateTimeEdit_2->dateTime();

    int sec = timePrev.secsTo(timeNow);
    int day = (sec/3600)/24;
    int hour = (sec/3600)%24;
    ui->label_3->setText("时间差为"+QString::number(day)+"天"+QString::number(hour)+"小时");
}
